package easycloud.ecs.provider.aliyun.model;

import java.util.Date;
import java.util.TimeZone;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.aliyun.openservices.oss.model.ObjectMetadata;

import easycloud.ecs.api.model.IStorageObjectMetadata;

public class AliyunStorageObjectMetadata implements IStorageObjectMetadata {

	private ObjectMetadata metadata;

	public AliyunStorageObjectMetadata(ObjectMetadata metadata) {
		this.metadata = metadata;
	}

	@Override
	public long getContentLength() {
		return metadata.getContentLength();
	}

	@Override
	public String getContentType() {
		return metadata.getContentType();
	}

	@Override
	public String getETag() {
		return metadata.getETag();
	}

	@Override
	public Date getLastModified() {
		return new Date(metadata.getLastModified().getTime()
				+ TimeZone.getDefault().getOffset(
						metadata.getLastModified().getTime()));
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("contentType", metadata.getContentType())
				.append("lastModified", metadata.getLastModified())
				.append("contentLength", metadata.getContentLength())
				.toString();
	}
}
